<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title></title>
<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<body class="pos-r">
<div class="pos-a" style="width:300px;left:0;top:0; bottom:0; height:100%; border-right:2px solid #e5e5e5; overflow:auto;padding-right: 10px;">
	  <table class="table table-border table-bordered table-hover table-bg table-sort" id="table1">
	    <tbody>
	      <tr class="text-c" th:each="attr:${attrSettingList}" >
	        <td th:text="${attr.name}" th:onclick="'javascript:show(\''+${attr.id}+'\',this)'"></td>
		  </tr>
	    </tbody>
	  </table>
</div>
<div style="margin-left:320px;" id="c">
	<!-- <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 产品管理 <span class="c-gray en">&gt;</span> 被审计机构 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav> -->
<div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-top: 0px;">
    <span class="l">
			<a href="javascript:;" onclick="attrsetting_add('添加','attrsetting-add')" class="btn btn-primary radius"><i class="icon-plus"></i> 添加</a>
			<a href="javascript:;" onclick="attrsetting_edit('编辑','attrsetting-edit')" class="btn radius"><i class="icon-trash"></i> 编辑</a>
			<a href="javascript:;" onclick="attrsetting_del()" class="btn btn-danger radius"><i class="icon-trash"></i> 删除</a>
		</span>
    <!-- <span class="r">共有数据：<strong>88</strong> 条</span> -->
  </div>
  <table class="table table-border table-bordered table-hover table-bg table-sort" id="table2">
    <thead>
      <tr class="text-c">
        <!--<th width="25"><input type="checkbox" name="" value=""></th>-->
        <th width="200">属性名称</th>
        <th width="200">属性类型</th>
				<th width="100">是否权限</th>
				<th width="100">是否多选</th>
      </tr>
    </thead>
    <tbody id="attr">

    </tbody>
  </table>
</div>
	</div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<!-- <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> -->
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<style>
	.back{background-color: #c2ccd1}
</style>
<script type="text/javascript">
var id = null;
function show(id,t) {
    $('#table1 tr').each(function(){
        $(this).css("background-color","");//还原所有td的颜色
        $(this).click(function(){
            $(this).css("background-color","rgb(245,245,245)");//设置点击td的颜色
        });
    });
    // t.style.backgroundColor = "#FFFFE0";
    this.id=id;
    $.ajax({
        type: "POST",
        url: "/showAttr?id="+id,
        success:function (data) {
           if (!data.length<1){
               $("#attr").html("");
               for (var i = 0;i< data.length;i++){
                   $("#attr").append(`
				<tr class="text-c" onclick="attrsetting(${data[i].attributes.id})">
					<!--<td><input type="checkbox" value="${data[i].attributes.id}" name="id"></td>-->
					<td>${data[i].attributes.name}</td>
					<td>${data[i].attributes.type}</td>
					<td>${data[i].attributes.purview}</td>
					<td>${data[i].attrSetting.mselect}</td>
                </tr>`)
               }
		   }else {
               $("#attr").html("");
		   }
        },
        error: function (error) {

        }
    });
}

function attrsetting_add(title,url){
    if (this.id ==null){
        layer.msg("请选择要添加的属性!",{icon:7,time:1500})
		return false;
	}
    layer.open({
        type: 2,
        title: title,
        shadeClose: false,
        shade: [0.3],
        maxmin: true, //开启最大化最小化按钮
        area: ['900px', '40%'],
        scrollbar: false, //屏蔽滚动条
        content: url+"?id="+this.id,
    });
}
var sid= null;
function attrsetting(sid) {
    $('#table2 tr:not(:first)').each(function(){
        $(this).css("background-color","");//还原所有td的颜色
        $(this).click(function(){
            $(this).css("background-color","rgb(245,245,245)");//设置点击td的颜色
        });
    });
    this.sid=sid;
}

function attrsetting_edit(title,url){
	if (this.sid==null){
	    layer.msg("请选择属性！👆",{icon:7,time:1400})
		return false;
	}
    layer.open({
        type: 2,
        title: title,
        shadeClose: false,
        shade: [0.3],
        maxmin: true, //开启最大化最小化按钮
        area: ['900px', '40%'],
        scrollbar: false, //屏蔽滚动条
        content: url+"?id="+this.sid,
    });
}

function attrsetting_del(){
    if (this.sid==null){
        layer.msg("请选择属性！👆",{icon:7,time:1400})
        return false;
    }
    $.ajax({
        type: "POST",
        url: "/delAttrsetting?sid="+this.sid,
        success:function (data) {
            if (data=="200") {
                layer.msg("删除成功！",{icon:1,time:2000})
                setTimeout(function () {
                    window.location.reload();
                },2000)
            }
        },
        error: function (error) {
            parent.layer.msg("删除失败！",{icon:1,time:2000})
        }
    });
}
// $('.table-sort').dataTable({
// 	"bStateSave": true,//状态保存
// 	"aoColumnDefs": [
// 	  {"orderable":false,"aTargets":[0,1,2,3,4,5]},// 制定列不参与排序
// 	]
// });
</script>
</body>
</html>